﻿/* 
 *mytab v1.0
 *Copyright (c) 2011 sdata007 
 *Creation date 2011-10-9
 *该组件基于jQuery，属于tab组件
*/
(function($){
	$.fn.myNav = function(options){
		var defaults = {
			navLink: ".mainNavLink",//标签
			navContent: ".mainNavContent",//标签主体内容
			navOn: ".mainNavLink",//鼠标经过添加样式
			navSelected: "mainNavOn",
			navIndex: 0
		}
		var options = $.extend(defaults,options);
		var thisTab = $(this);
		var oTimerIn, oTimerOut;
		$(thisTab).find(options.navLink).each(function(i){
			var oSelf = this;
			//绑定navLink
			$(oSelf).hover(function(){
				oSelf.oTimerIn = setTimeout(function(){
					$(thisTab).find(options.navOn).eq(options.navIndex).removeClass(options.navSelected);
					$(thisTab).find(options.navOn).eq(i).addClass(options.navSelected);
					$(thisTab).find(options.navContent).eq(options.navIndex).stop(true, true).slideUp(100);
					$(thisTab).find(options.navContent).eq(i).stop(true, true).slideDown(400);
					options.navIndex = i;							
				},150);																
			},function(){
				var oSelf = this;
				clearTimeout(oSelf.oTimerIn);
				oSelf.oTimerOut = setTimeout(function(){
					$(thisTab).find(options.navContent).stop(true, true).slideUp(100);															
				},150);
			});	
			$(thisTab).find(options.navContent).hover(function(){
				clearTimeout(oSelf.oTimerOut);	
			},function(){
				$(this).stop(true, true).slideUp(100);
			});										   
		});
	}		  
})(jQuery);